<div class="panel-heading">
    <a href="/admin/gift/edit" style="height:18px; padding:6px;">添加奖品</a>
    (总共 {{.Total}} 条记录)
</div>

<table class="table">
    <thead>
    <tr>
        <th>位置</th>
        <th>ID</th>
        <th title="【奖品池数量】">名称</th>
        <th title="总数 / 剩余数">数量</th>
        <th>概率</th>
        <th title="单位是天">周期</th>
        <th>图片</th>
        <th>类型</th>
        <th>数据</th>
        <th>开始时间</th>
        <th>结束时间</th>
        <th>更新时间</th>
        <th>管理</th>
    </tr>
    </thead>
    <tbody>
    {{range $i, $data := .Datalist}}

    <tr {{if eq $data.SysStatus 0}}class="success"{{end}}>
        <td>{{$data.Displayorder}}</td>
        <th scope="row">{{.Id}}</th>
        <td><a href="/admin/result?gift_id={{.Id}}">{{$data.Title}}</a></td>
        <td>{{$data.PrizeNum}} / {{.LeftNum}}</td>
        <td>{{$data.PrizeCode}}</td>
        <td title="{{FromUnixtime .PrizeBegin}} - {{FromUnixtime .PrizeEnd}}">
            <a href="#" data-toggle="modal" data-target="#myModal"
               onclick="showSharedGiftInfo('{{FromUnixtime .PrizeBegin}}', '{{FromUnixtime .PrizeEnd}}', '{{.PrizeData}}');return false;">
                {{$data.PrizeTime}}天计划</a>
        </td>
        <td><img src="{{$data.Img}}" width="50"/></td>
        <td>{{$data.Gtype}}</td>
        <td>{{$data.Gdata}}</td>
        <td>{{FromUnixtime $data.TimeBegin}}</td>
        <td>{{FromUnixtime $data.TimeEnd}}</td>
        <td>{{FromUnixtime $data.SysUpdated}}</td>
        <td>
            <a href="/admin/gift/edit?id={{.Id}}">修改</a>
        {{if eq $data.SysStatus 0}}
            <a href="/admin/gift/delete?id={{.Id}}">删除</a>
        {{else}}
            <a href="/admin/gift/reset?id={{.Id}}">恢复</a>
        {{end}}
        {{if eq .Gtype 2}}
            <br/>
            <a href="/admin/code?gift_id={{.Id}}">优惠券管理</a>
        {{end}}

        </td>
    </tr>

    {{end}}
    </tbody>
</table>

<!-- 模态框（Modal） -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">
                    发奖周期和计划
                </h4>
            </div>
            <div class="modal-body">
                开始时间：
                <span id="modal_time_begin">0</span>
                <br/>
                结束时间：
                <span id="modal_time_end">0</span>
                <br/>
                <div id="modal_list" style="height:300px; overflow: auto;"></div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                {{/*<button type="button" class="btn btn-primary">提交更改</button>*/}}
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>

<script>
function showSharedGiftInfo(pb, pe, data) {
    $('#modal_time_begin').html(pb);
    $('#modal_time_end').html(pe);
    var html = '';
    var i = 0;
    var datalist = JSON.parse(data);
    for(var t in datalist) {
        i += 1;
        var n = datalist[t];
        html = html + "&nbsp;&nbsp;" + i + "&nbsp;&nbsp;" + n + "<br/>\n";
    }
    $('#modal_list').html(html);
}
</script>